package cn.tedu.boot07.controller;

import cn.tedu.boot07.entity.Person;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AxiosController {
    @RequestMapping("/helloAxios")
    public String helloAxios(String name,Integer age){
        return "服务器接收到了请求!name="+name+" age="+age;
    }
    //如果客户端发出的是post请求,并且参数是自定义的JS对象
    //服务器接收参数时需要同样自定义一个对象来接收,并且通过@RequestBody注解修饰
    @RequestMapping("/postAxios")
    public String postAxios(@RequestBody Person person){
        return "测试成功!"+person.toString();
    }
}

